<template>
	<!-- 核销 -->
	<view class="hx">
		<u-loading style="margin-top: 100rpx;" v-if="status == ''" mode="circle"></u-loading>
		<view v-else class="">
			<u-image class="phinoe" src="@/static/offline/my/phinoe.png" mode="" width="185rpx" height="196rpx"></u-image>
			<u-image v-if="status == 1" class="sao-img" src="@/static/offline/my/hx_success.png" mode="" width="363rpx" height="75rpx"></u-image>
			<u-image v-if="status == 2" class="sao-img" src="@/static/offline/my/hx_fail.png" mode="" width="363rpx" height="75rpx"></u-image>
			<view v-if="status == 2" class="tip">
				<!-- 请让用户出示在快步APP订单详情里的核销码 -->
				{{msg}}
			</view>
			<u-button v-if="status == 1" style="margin: 195rpx 72rpx 0 72rpx;" type="primary" shape="circle" @click="toOrder">查看核销记录</u-button>
			<u-button v-if="status == 2" style="margin: 122rpx 72rpx 0 72rpx;" type="primary" shape="circle">再次扫描核销</u-button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			status: '',
			code: '',
			msg: ''
		}
	},
	onLoad(option) {
		this.code = option.code;
		if (this.code) {
			this.hx()
		} else {
			uni.showToast({
				title: '请扫码',
				icon:'none',
			})
		}
		
	},
	methods: {
		hx() {
			this.$u.offlineApi.scanCode({
				code: this.code
			}).then(res => {
				console.log('hhh',res)
				if (res.code == 0) {
					this.status = 1
				} else {
					this.status = 2
					this.msg = res.msg
					uni.showToast({
						icon:'none',
					    title: res.msg
					});
				}
			})
		},
		toOrder() {
			uni.switchTab({
				url: `/pages/offline/order/index`
			})
		}
	}
}
</script>

<style scoped>
	.hx {
		text-align: center;
	}
	.phinoe {
		margin: 287rpx auto 27rpx auto;
	}
	.sao-img {
		margin: 0 auto;
	}
	.tip {
		margin-top: 46rpx;
		color: #666666;
		font-size: 28rpx;
	}
</style>
